package ds.stack.app;

import ds.stack.StackX;

public class Reverse {

	private String input;
	private String output;
	
	public Reverse(String inputString) {
		input = inputString;
	}
	
	public String doRev() {
		
		StackX s = new StackX(input.length());
		
		for(int i=0;i<input.length();i++)
		{
			try {
				s.push(input.charAt(i));
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		output="";
		while(!s.isEmpty())
		{
			try {
				output += (char)s.pop();
				
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
		
		return output;
	}
	
	public static void main(String[] args)
	{
		Reverse r = new Reverse("QQmage");
		System.out.println(r.doRev());
	}
}
